<?php

namespace App\Repository\UpThree;

use App\Api\Transfer;
use App\Jobs\BigData;
use App\Jobs\OrderSubmit;
use App\Repository\Admin\AdminUsersLogRepository;
use App\Repository\BaseRepository;
use App\Repository\GetWay\WayRepository;
use App\Repository\Order\OrderChannelRepository;
use App\Repository\Order\OrderProductRepository;
use App\Repository\Order\OrderRepository;
use App\Repository\Product\GoodsRepository;
use App\Repository\Product\ProductRepository;
use App\Repository\Statist\CreateOrderStatistRepository;
use App\Repository\Stock\StockStistictRepository;
use Illuminate\Support\Facades\DB;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;

class BigDataRepostition extends BaseRepository
{
    private $goodsModel;
    private $productModel;
    private $orderProductModel;
    private $channelModel;
    private $orderModel;
    private $userMoneyLog;
    private $log;

    public function __construct()
    {
        $this->goodsModel = new GoodsRepository();
        $this->productModel = new ProductRepository();
        $this->orderProductModel = new OrderProductRepository();
        $this->channelModel = new OrderChannelRepository();
        $this->orderModel = new OrderRepository();
        $this->userMoneyLog = new AdminUsersLogRepository();
        $this->log = new Logger('bigDataRep');
        $this->log->pushHandler(
            (new RotatingFileHandler(storage_path('/logs/bigDataRep.log'), 14, Logger::DEBUG, true, 0777))->setFormatter(new LineFormatter(null, null, true, true))
        );
        parent::__construct();
    }

    public function index()
    {
    }

    // 抖音失败订单的推送信息  每隔10 分钟循环一次
    public function douyinSendDeliverDail($data = [], $page = 0)
    {
        $time = 10 * 60;
        if (empty($page)) {
            $page = 1;
        }
        $this->log->info('抖音验证时间' . time() . '手动推送数据页数' . $page . 'data参数' . json_encode($data));
        if (!empty($data['orderno'])) {
            $page = $data['orderno'];
        }
        // 1660211650 2022-08-12 16:07:38 时间
        // if (time() >= '1660291658') {
        //     return $this->returnMsg(101, '抖音推送测试结束');
        // }
        // $this->log->info('时间运算' . time());
        // dispatch(new BigData(1, 'douyinFail', $time))->onQueue('TaskBigDataDispose');
        // return $this->returnMsg(100, '测试时间' . $time);
        $nums = 10;
        $page = 1;
        $skip = ($page - 1) * $nums;
        $timeBack = date('Y-m-d H:i:s', strtotime('-47 hours', time()));
        // $timeBack = date('Y-m-d H:i:s', strtotime('-22 hours', time()));
        $timeBacks = date('Y-m-d H:i:s', strtotime('-45 hours', time()));
        // $timeBacks = date('Y-m-d H:i:s', strtotime('-24 hours', time()));
        $where = [];
        $where[] = ['is_delive', '=', 0];
        $where[] = ['created_at', '>=', $timeBack];
        $where[] = ['created_at', '<=', $timeBacks];
        $whereOr = false;
        if (!empty($whereOr)) {
            $datas = DB::table('douyin_catch')->where($where)->where(function ($query) use ($whereOr) {
                $query->orwhere(['goods_code' => '30元广辉卡90G'])->orwhere(['goods_code' => '29元广星卡284G'])->orwhere(['goods_code' => '49元广月卡329G']);
            })->take(10)->get();
            // $swl = DB::getQueryLog();
            // var_dump($swl);
        }
        if (empty($whereOr)) {
            $datas = DB::table('douyin_catch')->skip($skip)->where($where)->take($nums)->get();
        }
        // $swl = DB::getQueryLog();
        // var_dump($swl);die();
        $this->log->info('抖音回传失败信息' . json_encode($datas));
        // var_dump($datas);
        // die();
        $res = [
            'code' => '200',
            'msg' => '未查到数据'
        ];
        $model = new MainOrderRepostition();
        if (!empty($datas)) {
            $datas = json_decode(json_encode($datas), true);
            foreach ($datas as $key => $v) {

                $res['douyin'][] = $model->douYinSendDeliver($v, true, true);
            }
        }
        $page++;
        if (empty($datas) || count($datas) < $nums) {
            $page = 0;
        }
        // 设置 10分钟跑一次
        $time = 10;
        $this->log->info('抖音失败信息 设置10分钟后运行' . time());
        // 退款暂时停止
        dispatch(new BigData($page, 'douyinFail', $time))->onQueue('TaskBigDataDispose');
        // dispatch(new OrderSubmit(1, 'douyinFail', $time))->onQueue('TaskOrderSubmitDispose');
        return $res;
    }

    // 手动推送下失败信息
    public function pushManual($data = [], $page = 1, $nums = 50)
    {
        // 记录日志看有多少数据  10条 10条的推送数据
        $this->log->info('时间' . time() . '手动推送数据页数' . $page . 'data参数' . json_encode($data));
        $page = 1;
        if (!empty($data['orderno'])) {
            $page = $data['orderno'];
        }
        $nums = 10;
        $skip = ($page - 1) * $nums;
        // 每次推送 50 条
        $where = [
            'source' => 5,
            'shop_id' => 5,
        ];
        $datas = DB::table('order')->where($where)->skip($skip)->take($nums)->get();
        // $datas = DB::table('order')->where($where)->take($nums)->get();
        $res = [];
        $model = new MainOrderRepostition();
        if (!empty($datas)) {
            foreach ($datas as $key => $v) {
                $v = json_decode(json_encode($v), true);
                $res['pushmessage'] = $model->pushMessage($v, false); // 暂时不使用
            }
            $page++;
        }
        if (empty($datas) || count($datas) < $nums) {
            $page = 0;
        }
        if ($page > 0) {
            // 调用另外一个队列
            dispatch(new BigData($page, 'pushManual'))->onQueue('TaskBigDataDispose'); // 抖音失败返回
            // $res['er'] = $this->pushManual($page, $nums);
        }

        return $res;
    }

    // 验证抖音数据  一个小时 验证一次
    public function verificDouYin($data = [], $page = 1)
    {
        $nums = 10;
        if (empty($page)) {
            $page = 1;
        }
        $this->log->info('抖音验证时间' . time() . '手动推送数据页数' . $page . 'data参数' . json_encode($data));
        if (!empty($data['orderno'])) {
            $page = $data['orderno'];
        }
        $skip = ($page - 1) * $nums;
        $time = time() - (10 * 60);
        $times = date('Y-m-d H:i:s', $time);
        $where = [
            ['created_at', '<=', $times]
        ];
        $res = DB::table('douyin_catch_verific')->where('is_ver', 1)->where($where)->skip($skip)->take($nums)->get();

        if ($res) {
            foreach ($res as $key => $v) {
                $where = [
                    'dist_orderno' => $v->pid
                ];
                $isTrue = DB::table('douyin_catch')->where($where)->first();
                if ($isTrue) {
                    DB::table('douyin_catch_verific')->where(['pid' => $v->pid])->update(['is_ver' => 2]);
                    continue;
                }
                $data = [
                    'shop_id' => $v->shop_id,
                    'pid' => $v->pid,
                    'type' => 'douyin'
                ];
                dispatch(new OrderSubmit($data, 'catchOrder'))->onQueue('TaskOrderSubmitDispose');
            }
        }
        if (empty($res) || count($res) < $nums) {
            $page = 0;
            $time = 60 * 60;
            dispatch(new BigData(1, 'verificDouYin', $time))->onQueue('TaskBigDataDispose');
            return $this->returnMsg(200, '运行完成');
        }
        // 分页10s 处理一次
        $page++;
        dispatch(new BigData($page, 'verificDouYin', 10))->onQueue('TaskBigDataDispose');
        return $this->returnMsg(200, '分页读取' . $page);
    }

    // 主动请求第三方 获取订单的状态   一次跑一个月的数据  这个也是备用
    public function updateOrderStatus($data)
    {
        // 定时获取  每天 12点一次 下午七点运行一次
        $nums = 10;
        if (empty($page)) {
            $page = 1;
        }
        $this->log->info('订单获取数据' . time() . '手动推送数据页数' . $page . 'data参数' . json_encode($data));
        if (!empty($data['orderno'])) {
            $page = $data['orderno'];
        }
        $skip = ($page - 1) * $nums;
        $startTime = date('Y-m-d 00:00:00', strtotime('-3 day')); // 更新三天内的订单信息
        $where[] = ['created_at', '>=', $startTime];
        $where[] = ['status', '<', 50];
        // $where[] = ['sup_id', '=', 7];
        // 7 广州移动 3 省电信 6 感叹号
        $whereIn = [7, 3, 6];
        // DB::connection()->enableQueryLog();
        $res = DB::table('order')->where($where)->whereIn('sup_id', $whereIn)->skip($skip)->take($nums)->orderBy('sup_id', 'desc')->get();
        // $log = DB::getQueryLog();
        // var_dump($log);
        $this->log->info('查询参数:' . json_encode($where) . '返回参数' . json_encode($res));
        $model = new MainOrderRepostition();
        if ($res) {
            $res = json_decode(json_encode($res), true);
            foreach ($res as $key => $v) {
                $v = json_decode(json_encode($v), true); // 将订单处理下
                $return = $this->getOrderWay($v);
                if (empty($return)) {
                    continue;
                }
                // 将参数记录到 log日志中
                $this->log->info('更新状态时的得到的参数:' . json_encode($return));
                // var_dump($return);

                $datas = !empty($return['data'][0]) ? $return['data'][0] : [];
                if (!empty($datas) && !empty($datas['status'])) {
                    // $where = ['sup_orderno' => $datas['sup_order']];
                    // 查询条件可用上面 也可用这个
                    $where = ['orderno' => $v['orderno']];
                    $editData = [
                        'status' => $datas['status'],
                    ];
                    if ((!empty($datas['status']) && $datas['status'] == 20 && empty($datas['express_number']))) {
                        continue;
                    }
                    if (!empty($datas['express_number'])) {
                        $editData['express_number'] = $datas['express_number'];
                        $editData['express_company'] = $datas['express_company'];
                    }
                    if (!empty($datas['iccid'])) {
                        $editData['iccid'] = $datas['iccid'];
                    }
                    if (!empty($datas['three_msg'])) {
                        $editData['three_msg'] = $datas['three_msg'];
                    }
                    // 串号
                    if (!empty($datas['imei'])) {
                        $editData['imei'] = $datas['imei'];
                    }
                    // 是否首冲
                    if (!empty($datas['first_status'])) {
                        $editData['first_status_desc'] = $datas['first_status'];
                    }
                    // 修改订单状态
                    $resa = $model->editOrderThree($where, $editData);
                    $this->log->info('更新状态时的得到的参数:' . json_encode($return) . '修改后的结果' . !empty($resa) ? json_encode($resa) : '未修改');
                }

                // 修改订单状态
            }
        }
        if (empty($res) || count($res) < $nums) {
            $page = 0;
            // $times = date('Y-m-d 12:00:00', strtotime('+1 day'));
            // // 白天 3个小时更新一次
            // if (date('H') > 19) {
            //     $times = date('Y-m-d 19:00:00', strtotime('+1 day'));
            // }
            // $time = strtotime($times) - time();
            $time = 3 * 60 * 60; // 3个小时更新一次
            if (date('H') > 19) {
                $times = date('Y-m-d 07:00:00', strtotime('+1 day'));
                $time = strtotime($times) - time();
            }
            // var_dump($time, 1111111111);
            // dispatch(new BigData(1, 'updateOrderStatus', $time))->onQueue('TaskBigDataDispose');
            return $this->returnMsg(200, '运行完成');
        }
        // 分页10s 处理一次
        $page++;
        dispatch(new BigData($page, 'updateOrderStatus', 5))->onQueue('TaskBigDataDispose');
        return $this->returnMsg(200, '分页读取' . $page);
    }

    // 将渠道分开  这两个备用
    public function updateOrderStatus_manual($data, $channel_id = 0)
    {
        // 定时获取  每天 12点一次 下午七点运行一次
        $nums = 10;
        if (empty($page)) {
            $page = 1;
        }
        $this->log->info('人工订单获取数据' . time() . '手动推送数据页数' . $page . 'data参数' . json_encode($data));
        if (!empty($data['orderno'])) {
            $page = $data['orderno'];
        }
        $skip = ($page - 1) * $nums;
        $startTime = date('Y-m-d 00:00:00', strtotime('-3 day')); // 更新三天内的订单信息
        $where[] = ['created_at', '>=', $startTime];
        $where[] = ['status', '<', 50];
        // $where[] = ['sup_id', '=', 7];
        // 7 广州移动 3 省电信 6 感叹号
        $whereIn = [7, 3, 6];
        if (!empty($channel_id)) {
            $whereIn = [$channel_id];
        }

        // DB::connection()->enableQueryLog();
        $res = DB::table('order')->where($where)->whereIn('sup_id', $whereIn)->skip($skip)->take($nums)->orderBy('sup_id', 'desc')->get();
        // $log = DB::getQueryLog();
        // var_dump($log);
        $this->log->info('查询参数:' . json_encode($where) . '返回参数' . json_encode($res));
        $model = new MainOrderRepostition();
        if ($res) {
            $res = json_decode(json_encode($res), true);
            foreach ($res as $key => $v) {
                $v = json_decode(json_encode($v), true); // 将订单处理下
                $return = $this->getOrderWay($v);
                if (empty($return)) {
                    continue;
                }
                // 将参数记录到 log日志中
                $this->log->info('人工更新状态时的得到的参数:' . json_encode($return));
                // var_dump($return);

                $datas = !empty($return['data'][0]) ? $return['data'][0] : [];
                if (!empty($datas)) {
                    // $where = ['sup_orderno' => $datas['sup_order']];
                    // 查询条件可用上面 也可用这个
                    $where = ['orderno' => $v['orderno']];
                    $editData = [
                        'status' => $datas['status'],
                    ];
                    if ((!empty($datas['status']) && $datas['status'] == 20 && empty($datas['express_number']))) {
                        continue;
                    }
                    if (!empty($datas['express_number'])) {
                        $editData['express_number'] = $datas['express_number'];
                        $editData['express_company'] = $datas['express_company'];
                    }
                    if (!empty($datas['iccid'])) {
                        $editData['iccid'] = $datas['iccid'];
                    }
                    if (!empty($datas['three_msg'])) {
                        $editData['three_msg'] = $datas['three_msg'];
                    }
                    // 串号
                    if (!empty($datas['imei'])) {
                        $editData['imei'] = $datas['imei'];
                    }
                    // 是否首冲
                    if (!empty($datas['first_status'])) {
                        $editData['first_status_desc'] = $datas['first_status'];
                    }
                    // 修改订单状态
                    $resa = $model->editOrderThree($where, $editData);
                    $this->log->info('人工更新状态时的得到的参数:' . json_encode($return) . '修改后的结果' . !empty($resa) ? json_encode($resa) : '未修改');
                }

                // 修改订单状态
            }
        }
        if (empty($res) || count($res) < $nums) {
            $page = 0;
            // $times = date('Y-m-d 12:00:00', strtotime('+1 day'));
            // // 白天 3个小时更新一次
            // if (date('H') > 19) {
            //     $times = date('Y-m-d 19:00:00', strtotime('+1 day'));
            // }
            // $time = strtotime($times) - time();
            $time = 3 * 60 * 60; // 3个小时更新一次
            if (date('H') > 19) {
                $times = date('Y-m-d 07:00:00', strtotime('+1 day'));
                $time = strtotime($times) - time();
            }
            // var_dump($time, 1111111111);
            // dispatch(new BigData(1, 'updateOrderStatus', $time))->onQueue('TaskBigDataDispose');
            return $this->returnMsg(200, '运行完成');
        }
        // 分页10s 处理一次
        $page++;
        dispatch(new BigData($page, 'updateOrderStatus', 5))->onQueue('TaskBigDataDispose');
        return $this->returnMsg(200, '分页读取' . $page);
    }

    public function getOrderWay($order)
    {
        $model = new WayRepository();
        $resChannelModel = $model->getOne(['id' => $order['sup_id']]);
        if (!$resChannelModel) {
            return [];
        }
        if ($resChannelModel) {
            $resChannelModel = json_decode(json_encode($resChannelModel), true);
        }
        $order['model'] = $order['sup_id'];
        $data = array_merge($order, $resChannelModel);
        $model = new Transfer();
        return $model->queryOneOrder($data);
    }
    // 抖音数据 跑代理的抖音数据
    // 1: 商品信息 修改商品信息

    // 2: 添加抖音 房间号和名称
    public function agenDouYinOnorder()
    {
        $page = 1;
        $nums = 10;
        $skip = ($page - 1) * $nums;
        $res = DB::table('douyin_catch')->skip($skip)->take($nums)->get();
        $editData = [
            'shop_id' => 0,
            'sup_shop_id' => '',
            'sup_shop_name' => '',
            'sup_goods_name' => '',
            'sup_goods_id_str' => '',
            'shop_id_str' => '',
            'shop_name_str' => '',
            'source' => '6',
            'source_type' => '供应商抖音'
        ];
        // 修改提交
        $where = [
            'dist_orderno'
        ];
    }

    // 人工跑抖音分销商的数据 只需要跑一次
    public function handDouYinCathSendOrder_back($page = 0)
    {
        if (empty($page)) {
            $page = 1;
        }
        $nums = 10;
        $kip = ($page - 1) * $nums;
        $whereGetCatch = [
            'author_id' => '61487876010'
        ];
        $resDouYinCatch = DB::table('douyin_catch')->where($whereGetCatch)->skip($kip)->take($nums)->get();

        if (empty($resDouYinCatch) || count($resDouYinCatch) < $nums) {
            return '';
        }
        foreach ($resDouYinCatch as $key => $v) {
            // 需要修改的数据
            $update = [
                'author_id' => $v->author_id,
                'author_name' => $v->author_name,
            ];
            $whereOrder = [
                'dist_orderno' => $v->dist_orderno,
            ];
            $oneOrder = $this->orderModel->getOne($whereOrder);

            if (!$oneOrder) {
                continue;
            }
            var_dump($oneOrder, 1111111111);
            continue;
            $whereDis = [
                ['supplier_id', '=', $v->shop_id],
                ['dist_code', 'like', '%,' . $v->author_id . ',%'],
            ];
            // 获取员工
            $disArr = DB::table('supplier')->where($whereDis)->select(['name', 'shop_id'])->first();
            if (!$disArr) {
                continue;
            }
            $disUserId = $disArr->shop_id;
            // 判断这个订单是否是这个店铺的
            if ($oneOrder->shop_id == $disUserId) {
                continue;
            }

            $orderid = $oneOrder['id'];
            $dist_id = $disUserId;
            $goods_id = $oneOrder['goods_id'];
            $editData = $update;
            $res = $this->orderModel->editDistOne($orderid, $dist_id, $goods_id, $editData);
            $this->log->info('参数:' . json_encode($oneOrder) . '返回结果:' . json_encode($res));
        }
        return '';
    }

    public function handDouYinCathSendOrder($data = [], $page = 0)
    {
        if (!empty($data['orderno'])) {
            $page = $data['orderno'];
        }
        if (empty($page)) {
            $page = 1;
        }

        $nums = 10;
        $kip = ($page - 1) * $nums;
        $whereGetCatch[] = [
            'author_id', '>', 0
        ];
        $resDouYinCatch = DB::table('douyin_catch')->where($whereGetCatch)->skip($kip)->take($nums)->select('id', 'dist_orderno', 'author_id', 'author_name')->get();
        // var_dump($resDouYinCatch);
        // die();
        foreach ($resDouYinCatch as $key => $v) {
            // 需要修改的数据
            $update = [
                'author_id' => $v->author_id,
                'author_name' => $v->author_name,
            ];
            $whereOrder = [
                'dist_orderno' => $v->dist_orderno,
            ];
            $oneOrder = $this->orderModel->getOne($whereOrder);
            if (!$oneOrder) {
                continue;
            }
            DB::table('order')->where($whereOrder)->update($update);
        }
        if (empty($resDouYinCatch) || count($resDouYinCatch) < $nums) {
            return '';
        }
        $page++;
        dispatch(new BigData($page, 'handDouYinCathSendOrder', 10))->onQueue('TaskBigDataDispose');
        return '运行结束';
    }

    // 多个
    public function createMoreStatist($data = [], $time = '')
    {
        if (!empty($data['type']) && $data['type'] == 5) {
            $this->log->info('图标数据单个data数据:' . json_encode($data));
            $times = date('Y-m-d 00:00:01', $data['time']);
            return $this->createStatist($data, $times);
        }
        $data = DB::table('order_statist')->orderBy('id', 'desc')->first();
        if (!empty($data->created)) {
            // 跑多个数据
            $createdTime = strtotime($data->created);
            $endTime = strtotime(date('Y-m-d 00:00:00', strtotime('-1 day')));
            if ($createdTime != $endTime) {
                while ($createdTime < $endTime) {
                    $createdTime += 86400;
                    $data = [
                        'type' => 5,
                        'time' => $createdTime,
                        'orderno' => 1
                    ];
                    $this->log->info('图标数据:时间' . $createdTime . ',data数据:' . json_encode($data));
                    dispatch(new BigData($data, 'tableDatas', 5))->onQueue('TaskBigDataDispose');
                }
            }
        }
        $dataTime = date('Y-m-d 07:00:00', strtotime('+1 days'));
        $times = strtotime($dataTime) - time();
        // dispatch(new BigData(1, 'tableDatas',$times))->onQueue('TaskBigDataDispose');
        return $this->returnMsg(200, '运行完成');
    }

    // 图形表数据 跑数据  单个

    public function createStatist($data = [], $time = '', $isTrue = false)
    {
        $this->log->info('图标参数' . json_encode($data) . '时间:' . $time);
        if (empty($time)) {
            $time = date('Y-m-d', strtotime('-1 days'));
        }
        $model = new CreateOrderStatistRepository();
        $msg = '跑图片数据';
        $res = [];
        $product = 1;
        if (!empty($data['orderno']) && $data['orderno'] == 1) {
            $msg = '下单激活数据';
            $product = 2;
            $res = $model->createStatistOrder($time);
        }
        if (!empty($data['orderno']) && $data['orderno'] == 2) {
            $msg = '七天产品数据';
            $product = 3;
            $res = $model->createStatistProduct($time);
        }
        if (!empty($data['orderno']) && $data['orderno'] == 3) {
            $msg = '产品和代理的数据';
            $product = 4;
            $res = $model->createStatistProductAndDistOne($time);
        }
        $times = 5;
        if (!empty($data['orderno']) && $data['orderno'] <= 3) {
            $data['orderno'] = $product;
            $this->log->info('第二次参数:' . json_encode($data));
            dispatch(new BigData($data, 'tableDatas', $times))->onQueue('TaskBigDataDispose');
        }
        $startTime = strtotime($time);
        $endTime = strtotime(date('Y-m-d', strtotime('-1 days')));
        if (!empty($data['orderno']) && $data['orderno'] == 3 && $startTime == $endTime) {
            $dataTime = date('Y-m-d 07:00:00', strtotime('+1 days'));
            $times = strtotime($dataTime) - time();
            // dispatch(new BigData(1, 'tableDatas',$times))->onQueue('TaskBigDataDispose');
        }
        $this->log->info('图片数据浏览时间:' . $time . '信息' . $msg . '返回结果:' . json_encode($res));
        return $res;
    }

    // 存量数据图表 跑数据
    public function createStockStistict($data = [], $time = '', $type = '')
    {
        // 跑前一天的数据
        $timeStart = date('Y-m-d 00:00:00', strtotime('-1 day'));
        $timeEnd = date('Y-m-d 59:59:59', strtotime('-1 day'));
        if (!empty($time)) {
            $timeStart = date('Y-m-d 00:00:00', strtotime($time));
            $timeEnd = date('Y-m-d 23:59:59', strtotime($time));
        }
        $whereOrder[] = ['created_at', '>=', $timeStart];
        $whereOrder[] = ['created_at', '<=', $timeEnd];
        $resArr = DB::table('stock_order')->where($whereOrder)->select('page_id', DB::raw('count(*) as nums'), 'page_code', 'status', 'shop_id', 'page_name', 'three_msg', 'status_desc')->groupBy('page_id', 'page_code', 'status', 'shop_id', 'page_name', 'three_msg', 'status_desc')->get();
        $log = DB::getQueryLog();
        var_dump($log);
        $data = [];
        $model = new StockStistictRepository();  // 存入
        if ($resArr) {
            foreach ($resArr as $key => $v) {
                $datas = [
                    'count_nums' => $v->nums,
                    'page_id' => $v->page_id,
                    'page_name' => $v->page_name,
                    'shop_id' => $v->shop_id,
                    'page_code' => $v->page_code,
                    'three_msg' => $v->three_msg,
                    'status' => $v->status,
                    'time' => date('Y-m-d', strtotime($timeStart)),
                    'status_desc' => $v->status_desc
                ];
                $model->add($datas);
            }
        }
        // DB::table('stock_order_stistict')->insert($data);
        //

        // $time = '';
        // 每天凌晨三点操作
        $times = date('Y-m-d 03:00:00', strtotime('+1 day'));
        $time = strtotime($times) - time();
        $page = 0;
        dispatch(new BigData($page, 'updateOrderStatus', $time))->onQueue('TaskBigDataDispose');
        return $timeStart . '运行结束';
    }
}
